home *** CD-ROM | disk | FTP | other *** search
/ Network Support Library / RoseWare - Network Support Library.iso / apidev / mhs_c.arc / INPOST.ARC / OUTFILE.C < prev    next >
C/C++ Source or Header  |  1988-06-27  |  3KB  |  123 lines

  1. /* ******************************* OUTFILE.C ****************************** */
  2. #include "cctypes.h"
  3.  
  4. extern int OutFile;
  5. extern char OutExtension[];
  6. extern int ErrorsInThisFile;
  7. extern int WarningsInThisFile;
  8. extern char InFileName[];
  9. extern char OutFileName[];
  10. extern long fileSize;
  11. extern char messageBuffer[];
  12.  
  13. extern MCB MCBStruct;
  14.  
  15. int SetUpOutFile()
  16. {
  17.     int ccode;
  18.  
  19.     /* open the output file */
  20.     ccode = OpenOutputFile(OutExtension);
  21.         
  22.     if ( ccode)
  23.         return(CANNOT_CREATE_OUTPUT);
  24.  
  25.     return(0);
  26. }
  27.  
  28. void BlankLine()
  29. {
  30.     write(OutFile, "\15\12", 2); /* CR-LF */
  31. }
  32.  
  33. void WriteMCBFile()
  34. {
  35.     char temp[5];
  36.  
  37.     /* setup the (MCB) output */
  38.     if ( SetUpOutFile() ) {
  39.         Error(CANNOT_CREATE_OUTPUT);
  40.         return;
  41.     }
  42.  
  43.     /* 1 */
  44.     write(OutFile, MCBStruct.MHSVersion, strlen(MCBStruct.MHSVersion));
  45.     BlankLine();
  46.     /* 2 */
  47.     sprintf(temp, "%d", MCBStruct.headerLines);
  48.     write(OutFile, temp, strlen(temp));
  49.     BlankLine();
  50.     /* 3 */
  51.     sprintf(temp, "%d", MCBStruct.MCBType);
  52.     write(OutFile, temp, strlen(temp));
  53.     BlankLine();
  54.     /* 4 */
  55. /*     write(OutFile, MCBStruct.deliveryOptions, 1); */
  56.     BlankLine();
  57.     /* 5 */
  58.     write(OutFile, MCBStruct.originatingApplicationName,
  59.             strlen(MCBStruct.originatingApplicationName));
  60.     BlankLine();
  61.     /* 6 */
  62.     write(OutFile, MCBStruct.originatingUsername,
  63.             strlen(MCBStruct.originatingUsername));
  64.     BlankLine();
  65.     /* 7 */
  66.     write(OutFile, MCBStruct.originatingHost,
  67.             strlen(MCBStruct.originatingHost));
  68.     BlankLine();
  69.     /* 8 */
  70.     write(OutFile, MCBStruct.destinationUsername,
  71.             strlen(MCBStruct.destinationUsername));
  72.     BlankLine();
  73.     /* 9 */
  74.     write(OutFile, MCBStruct.destinationHost,
  75.             strlen(MCBStruct.destinationHost));
  76.     BlankLine();
  77.     /* 10 */
  78.     write(OutFile, MCBStruct.messageSubject,
  79.             strlen(MCBStruct.messageSubject));
  80.     BlankLine();
  81.     /* 11 */
  82.     write(OutFile, MCBStruct.attachmentFilename,
  83.             strlen(MCBStruct.attachmentFilename));
  84.     BlankLine();
  85.     /* 12 */
  86.     /* blank line for sealed message ID*/
  87.     BlankLine();
  88.     /* 13 */
  89.     /* blank line for referenced message ID */
  90.     BlankLine();
  91.     /* 14 */
  92.     /* blank line for date sealed */
  93.     BlankLine();
  94.     /* 15 */
  95.     /* blank line for date unsealed */
  96.     BlankLine();
  97.     /* 16 */
  98.     sprintf(temp, "%d", MCBStruct.contentTypeOfAttachmentFile);
  99.     write(OutFile, temp, strlen(temp));
  100.     BlankLine();
  101.     /* 17 */
  102.     /* blank line for status report */
  103.     BlankLine();
  104.     /* 18 */
  105.     /* last line in MCB */
  106.     BlankLine();
  107.  
  108.     if ( strlen(messageBuffer) )
  109.         write(OutFile, messageBuffer, strlen(messageBuffer));
  110.  
  111.     fileSize = lseek(OutFile,(long)0,2);
  112.     close(OutFile);
  113.  
  114.     if ( ErrorsInThisFile ) {
  115. /*         unlink(OutFileName); */
  116.         ErrorsInThisFile = 0;
  117.     }
  118.  
  119.     return;
  120. }
  121.  
  122.  
  123.